package com.kly.cashmall.popup;

import android.app.Activity;
import android.widget.TextView;

import com.kly.cashmall.R;
import com.kly.cashmall.bean.ExtensionDetailBean;
import com.kly.cashmall.utils.ViewHolder;

import razerdp.basepopup.BasePopupWindow;

/**
 * @author
 */
public class ExceedingPopupWindow extends BasePopupWindow {

    private final Callback callback;
    private Activity activity;
    private TextView mExtendedDays;
    private TextView mExceedingTips;
    private TextView mExceedingRepaymentDateText;
    private TextView mExceedingExtendedServiceFeeText;
    private TextView mExceedingClose;
    private TextView mExceedingOk;


    public ExceedingPopupWindow(Activity activity, ExtensionDetailBean extensionDetailBean, Callback callback) {
        super(activity);
        setContentView(R.layout.popup_exceeding);
        this.activity = activity;
        this.callback = callback;
        showPopWindow(extensionDetailBean);
    }

    private void showPopWindow(ExtensionDetailBean extensionDetailBean) {
        initView();
        initEvent(extensionDetailBean);
    }

    private void initEvent(ExtensionDetailBean extensionDetailBean) {
        mExceedingTips.setText(extensionDetailBean.getTips());
        mExtendedDays.setText(extensionDetailBean.getExtensionDays());
        mExceedingRepaymentDateText.setText(extensionDetailBean.getExtensionDate());
        mExceedingExtendedServiceFeeText.setText(extensionDetailBean.getExtensionFee());
        mExceedingClose.setOnClickListener(view -> {
            dismiss();
        });
        mExceedingOk.setOnClickListener(view -> {
            callback.onClickListener();
            dismiss();
        });
    }

    private void initView() {
        ViewHolder viewHolder = ViewHolder.getHolder(getContentView());
        mExceedingTips = viewHolder.getView(R.id.exceeding_tips);
        mExceedingRepaymentDateText = viewHolder.getView(R.id.exceeding_repayment_date_text);
        mExceedingExtendedServiceFeeText = viewHolder.getView(R.id.exceeding_extended_service_fee_text);
        mExtendedDays = viewHolder.getView(R.id.exceeding_extended_days_size);
        mExceedingClose = viewHolder.getView(R.id.exceeding_close);
        mExceedingOk = viewHolder.getView(R.id.exceeding_ok);
    }

    public interface Callback {
        void onClickListener();
    }

}
